import time

import yaml

from selenium.webdriver.common.by import By

from wecom_practice.base.base_page import BasePage


class WeworkLogin(BasePage):
    def get_login_cookie(self):
        '''
        手动扫码登录企业微信web端，获取cookie信息
        :return:
        '''
        self.driver.get("https://work.weixin.qq.com/")
        self.driver.find_element(By.XPATH, "//*[text()='企业登录']").click()
        time.sleep(30)
        cookie = self.driver.get_cookies()
        print(cookie)
        with open("cookie.yaml", "w") as f:
            yaml.safe_dump(cookie, f)

if __name__ == '__main__':
    WeworkLogin().get_login_cookie()